import 'package:flutter/material.dart';
import 'package:multi_image_picker/multi_image_picker.dart';

/// 图片预览组件，带删除图标。
class ItemImagePreview extends StatelessWidget {
  final Asset asset;
  final GestureTapCallback onTap;

  const ItemImagePreview(this.asset, {Key key, this.onTap}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        // 图片
        Padding(
          padding: const EdgeInsets.all(12.0),
          child: ClipRRect(
            borderRadius: BorderRadius.all(Radius.circular(5)),
            child: AssetThumb(
              asset: asset,
              width: 300,
              height: 300,
            ),
          ),
        ),
        // 删除图标
        Positioned(
          child: InkWell(
            child: Container(
              padding: const EdgeInsets.all(5.0),
              child: Image.asset(
                'assets/images/ic_delete.png',
                width: 18,
                height: 18,
              ),
            ),
            onTap: onTap,
          ),
          right: 0,
          top: 0,
        )
      ],
    );
  }
}
